Class pyglet.image.atlas.TextureAtlas

Collection of images within a texture.

Methods

  __init__(self, width=256, height=256)
Create a texture atlas of the given size.
TextureRegion add(self, img)
Add an image to the atlas.

Method Details

__init__

(Constructor) __init__(self, width=256, height=256)
Create a texture atlas of the given size.
Parameters:
width : int
Width of the underlying texture.
height : int
Height of the underlying texture.

add

add(self, img)

Add an image to the atlas.

This method will fail if the given image cannot be transferred directly to a texture (for example, if it is another texture). ImageData is the usual image type for this method.

AllocatorException will be raised if there is no room in the atlas for the image.

Parameters:
img : AbstractImage
The image to add.
Returns:
TextureRegion: The region of the atlas containing the newly added image.